<template>
	<view class="container">
		<u-card v-for="(item,index) in courseContent" :title="item.title" :border="true" :foot-border-top="false" padding="20">
			<view class="" slot="body">
				<week-content :item="item"></week-content>
			</view>
		</u-card>
		<u-empty v-if="courseContent.length === 0" text="暂时没有内容哦～"  mode="list"></u-empty>
	</view>
</template>

<script>
	import WeekContent from './components/week-content.vue'
	import PictureBook from './components/picture-book.vue'
	import Music from './components/music.vue'
	import GiftBox from './components/gift-box.vue'
	import appMixin from '@/mixins/app.js'
	import { getCategoryTypeByGuide, getCategoryTypeByGuideByFamily } from '@/api/course'
	import {
		mapState,
	} from 'vuex';
	export default {
		components: {
			WeekContent,
			PictureBook,
			Music,
			GiftBox
		},
		mixins: [appMixin],
		computed: {
			...mapState({
				appType: state => state.app.appType,
			}),
		},
		data() {
			return {
				courseContent: []
			}
		},
		onLoad(options) {
			console.log(options)
			this.courseId = options.courseId;
			this.categoryType = options.categoryType;
			this.getWeekDetails()
		},
		methods: {
			getWeekDetails() {
				const { courseId, categoryType } = this;
				
				let f = getCategoryTypeByGuide
				if (this.appType === 'app-p' || this.appType === 'mp-p') {
					f = getCategoryTypeByGuideByFamily
				}
				f({courseId, categoryType}).then(res => {
					console.log(res)
					this.courseContent = res.data
				})
			}
		}
	}
</script>

<style lang="scss">
	page{
		background-color: $app-page-bg-color;
	}
	
	.container{
	}
</style>
